package com.example.chapter;

import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import com.example.chapter.util.DateUtil;

public class ButtonLongClickActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_button_long_click);
        TextView blc_result = findViewById(R.id.blc_result);
        Button blc_click = findViewById(R.id.blc_click);

        blc_click.setOnLongClickListener(v -> {
            String desc = String.format("%s 您点击了按钮: %s", DateUtil.getNowTime(), ((Button) v).getText());
            blc_result.setText(desc);
            return true;
        });
    }
}